package com.tanjun.userservice.web.event.handler;

import com.alibaba.fastjson2.JSONObject;
import com.tanjun.userservice.web.event.BaseEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;

@Component
@Slf4j
public class BaseEventListener {

    @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true)
    public void onApplicationEvent(BaseEvent event) {
        log.info("event:{}", JSONObject.toJSONString(event));
    }
}
